package com.jd.system.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jd.system.entity.Test;
import com.jd.system.result.Result;
import com.jd.system.services.TestService;
import com.jd.system.util.RedisUtil;
import com.jd.system.result.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    TestService testService;
    @Autowired
    private HttpServletRequest request;
    @Resource
    private RedisUtil redisUtil;

    private ResultJson resultJson = new ResultJson();

    @ResponseBody
    @RequestMapping(value = "/test1", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public JSONObject Test1(@RequestBody Test test) {
        return JSON.parseObject(JSON.toJSONString(resultJson));
    }

    @GetMapping("/test2")
    public JSONObject Test2(
                               @RequestParam(name="page",defaultValue = "0") String num,
                               @RequestParam(name="size",defaultValue = "0") String size) {
        System.out.println("test2");
        //始发地址
        String start_province_num;
        String start_city_num;
        String start_county_num;
        String start_village_num;
        //目的地址
        String aim_province_num;
        String aim_city_num;
        String aim_county_num;
        String aim_village_num;
        //下单时间
        String order_time = "2021/05/01 19:20";

        resultJson = Result.success(testService.test());
        return JSON.parseObject(JSON.toJSONString(resultJson));
    }

}
